package jinyilw.swing.rlaf.theme;

import jinyilw.swing.ResourceManager;
import jinyilw.swing.rlaf.UISettable;
import jinyilw.swing.rlaf.UITools;

import java.awt.Color;
import java.awt.Image;

public class RRootPaneSet implements UISettable
{
	private static volatile RRootPaneSet rootPaneSet/* = new RRootPaneSet() */;
	public Color bgColor;
	public Image bgImage;

	private RRootPaneSet()
	{
		UITools.installUITheme(this);
	}

	public static RRootPaneSet getRootPaneSet()
	{
		if (rootPaneSet == null)
			synchronized (RRootPaneSet.class)
			{
				if (rootPaneSet == null)
					rootPaneSet = new RRootPaneSet();
			}
		return rootPaneSet;
	}

	@Override
	public void lightTheme()
	{
		bgColor = RColorSet.lightBGColor;
		bgImage = UITools.lightImage;
	}

	@Override
	public void darkTheme()
	{
		bgColor = Color.gray;
		bgImage = UITools.darkImage;
	}

	@Override
	public void blackTheme()
	{
		bgColor = Color.darkGray;
		bgImage = UITools.blackImage;
	}

	static Image lightImage, darkImage, blackImage;

	public static Image getDefaultLightImage()
	{
		if (lightImage == null)
			lightImage = UITools.getColoredImage(
					ResourceManager.getBufferedImage(RRootPaneSet.class,
							"bg/light.jpg"), UITools.lightTheme);
		return lightImage;
	}

	public static Image getDefaultDarkImage()
	{
		if (darkImage == null)
			darkImage =
					UITools.getColoredImage(ResourceManager.getBufferedImage(RRootPaneSet.class,
					"bg/dark.jpg"), UITools.darkTheme);
		return darkImage;
	}

	public static Image getDefaultBlackImage()
	{
		if (blackImage == null)
			blackImage = UITools.getColoredImage(
					ResourceManager.getBufferedImage(RRootPaneSet.class,
							"bg/black.jpg"), UITools.blackTheme);
		return blackImage;
	}
}
